//
//  DescCell.m
//  quickDoctor
//
//  Created by zhaowei on 17/3/10.
//  Copyright © 2017年 SWS. All rights reserved.
//

#import "DescCell.h"

@interface DescCell()<UITextViewDelegate>


@end
@implementation DescCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    if(self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        [self setupUI];
    }
    return self;
}
#pragma mark
#pragma mark -初始化界面
- (void)setupUI{
    //添加label
    UILabel *label = [[UILabel alloc] init];
    [label sizeToFit];
    label.text = @"病症描述:";
    [self.contentView addSubview:label];
    
    //约束label
    [label mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.offset(10);
        make.leading.offset(0);
    }];
    
    //添加textView
    UITextView *textView = [[UITextView alloc] init];
    _textView = textView;
    textView.backgroundColor = [UIColor grayColor];
    textView.text = @"请输入病症描述";
    textView.textColor = [UIColor greenColor];
    textView.delegate = self;
    
    //键盘类型
    textView.keyboardType = UIKeyboardTypeDefault;
    [self.contentView addSubview:textView];
    
    //约束
    [textView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(label.mas_bottom).offset(8);
        make.leading.offset(10);
        make.trailing.offset(-10);
        make.height.mas_equalTo(150);
    }];
}

#pragma mark
#pragma mark -textView的代理方法
- (void)textViewDidEndEditing:(UITextView *)textView {
    if(textView.text.length <1) {
        textView.text = @"请输入病症描述";
        textView.textColor = [UIColor lightTextColor];
    }
//    [textView resignFirstResponder];
}

- (void)textViewDidBeginEditing:(UITextView *)textView {
    if([textView.text isEqualToString:@"请输入病症描述"]) {
        textView.text = @"";
        textView.textColor = [UIColor greenColor];
    }
}


@end
